import org.apache.commons.httpclient.HttpClient;
import org.testng.annotations.DataProvider;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class RequestCommon {
    HttpClient httpClient;

    public RequestCommon() {
        httpClient = new HttpClient();
    }



    public Object[][] getCsv(String filepath) {
        Object[][] results = new Object[0][];
        try {
            List<String[]> arrayList = new ArrayList<String[]>();
            String readLine;
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(filepath), "UTF-8"));
            while ((readLine = bufferedReader.readLine()) != null) {
                String fileds[] = readLine.split(",");
                arrayList.add(fileds);
            }
            bufferedReader.close();
            results = new Object[arrayList.size()][];
            for (int i = 0; i < arrayList.size(); i++) {
                results[i] = (Object[]) arrayList.get(i);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return results;
    }
}
